//引入axios
import request from '@/utils/request.js';

//获取用户信息
export function getUsersinfo() {
  const id = localStorage.getItem('UserId');
  const url  = `users/${id}`;
  return request({
    url: url,
    method: 'get',
    params: '',
    headers: {
        'Content-Type': 'application/json',
        addToken: true      // 指示需要在请求头中添加 token
      }
  })
}

//更新用户信息
export function updateUserInfo(data) {
    const id = localStorage.getItem('UserId');
    const url  = `users/${id}`;
    return request({
      url: url,
      method: 'put',
      data: data,
      headers: {
          'Content-Type': 'application/json',
          addToken: true      // 指示需要在请求头中添加 token
        }
    })
  }
